package com.yazi.mxz.common.db.dao.impl;



import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.yazi.mxz.common.db.dao.CompanyMemberDao;
import com.yazi.mxz.common.entity.beans.CompanyMember;
import com.yazi.mxz.common.entity.beans.CompanyMemberId;

import com.myframework.smhj.hibernate.dao.BasicDao;

@Repository("companyMemberDao")
public class CompanyMemberDaoImpl extends BasicDao<CompanyMember> implements CompanyMemberDao {

	
	public CompanyMemberDaoImpl() {
		super(CompanyMember.class);
		
	}

	@Override
	public Criteria getExample(CompanyMember cm, String searchWord) {
		Criteria c = super.getExample(cm, searchWord);
		
		// 关联对象条件
		if (null != cm) {
			// ID
			CompanyMemberId cmId = cm.getId();
			if (null != cmId) {
				if (null != cmId.getMemberId()) {
					c.add(Restrictions.eq("id.memberId", cmId.getMemberId()));
				}
				if (null != cmId.getCompanyId()) {
					c.add(Restrictions.eq("id.companyId", cmId.getCompanyId()));
				}
			}
			// ...其它关联对象条件
		}

		// ...关键字searchWord条件
		
		return c;
	}

}
